// 这是专门书写用户相关的api
import request from '@/utils/request'

// 限制用户登录时传递的参数
export interface UserLoginType {
    username: string,
    password: string
}

// 限制用户登录的返回值
export interface returnUserLoginType {
    token: string
}

// 1- 用户的登录
export const reqPostLoginAsync = (userInfo: UserLoginType) => {
    return request.post<null, returnUserLoginType>(`/admin/acl/index/login`, userInfo)
}

// 限制用户信息的类型
export interface UserInfoType {
    routes: string[],
    buttons: string[],
    roles: string[],
    name: string,
    avatar: string
}

// 2- 获取用户信息
export const reqGetUserInfo = () => {
    return request.get<null, UserInfoType>(`/admin/acl/index/info`)
}

// 3- 退出登录
export const reqPostLoginOutAsync = () => {
    return request.post<null, null>(`/admin/acl/index/logout`)
}
